package src.leetcode.dp.medium_0377;

public class combinationSum4 {
    public static void main(String[] args) {
        Solution solution = new Solution();
        System.out.println(solution.combinationSum4(new int[]{1, 2, 3}, 4));
    }

}


class Solution {
    public int combinationSum4(int[] nums, int target) {
        int []dp = new int[target + 1];

        dp[0] = 1;

        for(int i = 0; i < target + 1; i++){
            for (int num : nums) {
                if(i - num < 0) continue;
                dp[i] += dp[i - num];
            }
        }

        return dp[target];
    }
}